﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using StarTrek.Weapon;
using StarTrek.World;

namespace StarTrek.UI.Console.MenuItem
{
    class MenuStatus:iMenuItem
    {
        private static readonly string INDENT = new string(' ', 8);
        #region iMenuItem Members

        public bool ProcessSomeRequest(MenuContext Menu, TextWriter sw, TextReader tr)
        {
            bool rVal = (Menu.Action == MenuAction);

            if (rVal)
            {
                MenuStatus.Draw(Menu,sw,tr);
            }
            return rVal;

        }

        public static void Draw(MenuContext Menu, TextWriter sw, TextReader tr)
        {
                //Perform Action
                Galaxy theWorld = Galaxy.Instance;
                ShipStatus ship = theWorld.CurrentShip.CreateShipStatus();


                if (ship.HullStrength > 0)
                {
                    sw.WriteLine(Menu.wordWrap(String.Format(Properties.Resources.MenuStatus1, ship.Name, 
                                                    ship.ShieldStrength*100,
                                                    ship.HullStrength*100)));
                    sw.WriteLine(Menu.wordWrap(String.Format(Properties.Resources.MenuStatus2, ship.Name, 
                                                    ship.ShieldStrength*100,
                                                    ship.HullStrength*100)));
                    sw.WriteLine(Menu.wordWrap(String.Format(Properties.Resources.MenuStatus3, ship.Name, 
                                                    ship.ShieldStrength*100,
                                                    ship.HullStrength*100)));

                    foreach (string s in ship.WeaponOperationalStatus())
                    {
                        sw.WriteLine("{0}{1}", INDENT, Menu.wordWrap(s));
                    }
                }
                else
                {
                    sw.WriteLine(Menu.wordWrap(Properties.Resources.MenuStatusDead));
                }
        }

        public string MenuAction
        {
            get { return "S"; }
        }

        public string Text
        {
            get { return Properties.Resources.MenuStatusText; }
        }

        public string VerboseText
        {
            get { return Properties.Resources.MenuRepairVerbose; }
        }
        #endregion
    }
}
